﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cocos2d;

namespace RunCircle
{
    class TrapBanana : Trap
    {
        List<CCSpriteFrame> m_AnimFrames;
        public TrapBanana()
        {
            m_TrapType = "Trap_Banana";

            m_AnimFrames = new List<CCSpriteFrame>();
            //string framename00 = "banana_1.png";
            //CCSpriteFrame spriteframe_00 = CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(framename00);
            string framename01 = "banana_2.png";
            CCSpriteFrame spriteframe_01 = CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(framename01);
            //m_AnimFrames.Add(spriteframe_00);
            m_AnimFrames.Add(spriteframe_01);

            initWithSpriteFrameName(framename01);
            CCSpriteFrame frame = CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(framename01);
            this.width = frame.Rect.size.width;
            height = frame.Rect.size.height;

            playAnimation();
        }

        private void playAnimation()
        {
            CCAnimation ani = CCAnimation.animationWithFrames(m_AnimFrames);
            CCAnimate animaction = CCAnimate.actionWithDuration(1.0f, ani, true);
            this.runAction(CCRepeatForever.actionWithAction(animaction));
        }

        public override void update(float dt)
        {
            base.update(dt);
        }

        public override bool checkCollision()
        {
            return false;
        }
    }
}
